<template>
	<div class="lifeStyle">
		<v-table ref="vTable" :tableColumns="tableColumns" :tableData="tableData"></v-table>
		<Collapse v-model="value" class='collapse'>
			<Panel name="1">
				饮食指导
				<div class="wrapbox" slot="content">
					<Button class="addbutton" icon="plus-round" type="dashed" @click="showDiet">新增饮食指导</Button>
					<div class="header">饮食指导</div>
					<v-table ref="vTableTwo" :tableColumns="tableColumnsTwo" :tableData="tableData2"></v-table>
					<p class="remarks">注：加餐的食用时间请在早餐后的2个小时食用</p>
				</div>
			</Panel>
			<Panel name="2">
				尽量少选的食物
				<div class="wrapbox" slot="content">
					<Button class="addbutton" icon="plus-round" type="dashed" @click="showFoods">新增尽量少选的食物</Button>
					<div class="header">尽量少选的食物</div>
					<v-table ref="vTableThree" :tableColumns="tableColumnsThree" :tableData="tableData3"></v-table>
				</div>
			</Panel>
			<Panel name="3">
				运动指导
				<div class="wrapbox" slot="content">
					<Button class="addbutton" icon="plus-round" type="dashed" @click="showMotion">新增运动指导</Button>
					<div class="header">运动指导</div>
					<v-table ref="vTableFour" :tableColumns="tableColumnsFour" :tableData="tableData4"></v-table>
				</div> 
			</Panel>
			<Panel name="4">
				睡眠指导
				<div class="wrapbox" slot="content">
					<div class="header">睡眠指导</div>
					<Input type="textarea" v-model="sleepData.guidance" disabled :autosize="{minRows: 5}" placeholder="Enter something..."/>
					<div class="button-box">
						<Button type='primary' class="editTarget" @click="showSleep">编辑</Button>
					</div>
				</div> 
			</Panel>
			<Panel name="5">
				心理指导
				<div class="wrapbox" slot="content">
					<div class="header">心理指导</div>
					<Input type="textarea" v-model="psychologyData.psychologyGuidance" disabled :autosize="{minRows: 5}" placeholder="Enter something..."/>
					<div class="button-box">
						<Button type='primary' class="editTarget" @click="showPsychology">编辑</Button>
					</div>
				</div> 
			</Panel>
		</Collapse>
			
		<!-- 信息头部 编辑  -->
		<!--<Modal v-model="isInfoShow" :width="400" class-name="eidthform" :mask-closable='false'>
			<p slot="header">信息编辑</p>
			<Form ref="infoForm" :model="infoData" :label-width="70">
				<FormItem label="身高:">
	                <Input type="text" v-model="infoData.height" placeholder="请输入身高"></Input>
	            </FormItem>
	            <FormItem label="体重:">
	                <Input type="text" v-model="infoData.weight" placeholder="请输入身高"></Input>
	            </FormItem>
	            <FormItem label="BMI:">
	                <Input type="text" v-model="infoData.name" placeholder="请输入BMI"></Input>
	            </FormItem>
	            <FormItem label="腰围:">
	                <Input type="text" v-model="infoData.date" placeholder="请输入腰围"></Input>
	            </FormItem>
	            <FormItem label="臀围:">
	                <Input type="text" v-model="infoData.address" placeholder="请输入腰围"></Input>
	            </FormItem>
	            <FormItem label="理想体重:">
	                <Input type="text" v-model="infoData.kgWeight" placeholder="请输入腰围"></Input>
	            </FormItem>
	            <FormItem label="总热量:">
	                <Input type="text" v-model="infoData.age" placeholder="请输入腰围"></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="infoKeep"  @click="keepInfo('infoForm')">保存</Button>
	            <Button type="ghost" @click="infoCancel('infoForm', 'isInfoShow')">取消</Button>
	        </div>
		</Modal>-->
		
		<!-- 饮食指导 编辑 -->
		<Modal v-model="isDietShow" :width="500" class-name="eidthform" :mask-closable='false'>
			<p slot="header">{{editFormTitle}}</p>
			<Form ref="dietForm" :model="dietData" :label-width="70">
				<FormItem label="时间:">
	                <Select v-model="dietData.foodCategory" placeholder="请选择时间" style="width: 100%">
						<Option value="早餐">早餐</Option>
						<Option value="中餐">中餐</Option>
						<Option value="晚餐">晚餐</Option>
						<Option value="加餐">加餐</Option>
					</Select>
	            </FormItem>
				<FormItem label="主食类:">
	                <Input type="text" v-model="dietData.stapleFood" placeholder="请输入主食类"></Input>
	            </FormItem>
	            <FormItem label="肉蛋白类:">
	                <Input type="text" v-model="dietData.proteinFood" placeholder="请输入肉蛋白类"></Input>
	            </FormItem>
	            <FormItem label="蔬菜类:">
	                <Input type="text" v-model="dietData.vegetableFood" placeholder="请输入蔬菜类"></Input>
	            </FormItem>
	            <FormItem label="奶类:">
	                <Input type="text" v-model="dietData.milkFood" placeholder="请输入奶类"></Input>
	            </FormItem>
	            <FormItem label="水果类:">
	                <Input type="text" v-model="dietData.fruitFood" placeholder="请输入水果类"></Input>
	            </FormItem>
	            <FormItem label="植物类:">
	                <Input type="text" v-model="dietData.oil" placeholder="请输入植物类"></Input>
	            </FormItem>
	            <FormItem label="食盐:">
	                <Input type="text" v-model="dietData.salt" placeholder="请输入食盐"></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="dietKeep"  @click="keepDiet('dietForm')">保存</Button>
	            <Button type="ghost" @click="dietCancel('dietForm', 'isDietShow')">取消</Button>
	        </div>
		</Modal>
	
		<!-- 尽量少选的食物 编辑 -->
		<Modal v-model="isFoodsShow" :width="500" class-name="eidthform" :mask-closable='false'>
			<p slot="header">{{editFormTitle2}}</p>
			<Form ref="foodsForm" :model="foodsData" :label-width="100">
				<FormItem label="高升糖指数食品:">
	                <Input type="text" v-model="foodsData.sugarManyFood" placeholder="请输入高升糖指数食品"></Input>
	            </FormItem>
	            <FormItem label="高升糖指数水果:">
	                <Input type="text" v-model="foodsData.sugarManyFruit" placeholder="请输入高升糖指数水果"></Input>
	            </FormItem>
	            <FormItem label="高盐食品:">
	                <Input type="text" v-model="foodsData.saltManyFood" placeholder="请输入高盐食品"></Input>
	            </FormItem>
	            <FormItem label="高胆固醇食品:">
	                <Input type="text" v-model="foodsData.cholesterolManyFood" placeholder="请输入高胆固醇食品"></Input>
	            </FormItem>
	            <FormItem label="油炸食品:">
	                <Input type="text" v-model="foodsData.oilFood" placeholder="请输入油炸食品"></Input>
	            </FormItem>
	            <FormItem label="其他加工食品:">
	                <Input type="text" v-model="foodsData.otherFood" placeholder="请输入其他加工食品"></Input>
	            </FormItem>
	            <FormItem label="高嘌呤食物:">
	                <Input type="text" v-model="foodsData.purineManyFood" placeholder="请输入高嘌呤食物"></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="foodsKeep"  @click="keepFoods('foodsForm')">保存</Button>
	            <Button type="ghost" @click="foodsCancel('foodsForm', 'isFoodsShow')">取消</Button>
	        </div>
		</Modal>
	
		<!-- 运动指导 编辑 -->
		<Modal v-model="isMotionShow" :width="400" class-name="eidthform" :mask-closable='false'>
			<p slot="header">{{editFormTitle3}}</p>
			<Form ref="mitionForm" :model="mitionData" :label-width="70">
				<FormItem label="运动方式:">
	                <Input type="text" v-model="mitionData.sportCategory" placeholder="请输入运动方式"></Input>
	            </FormItem>
	            <FormItem label="运动强度:">
	                <Input type="text" v-model="mitionData.sportDose" placeholder="请输入运动强度"></Input>
	            </FormItem>
	            <FormItem label="运动时间:">
	                <Input type="text" v-model="mitionData.sportTime" placeholder="请输入运动时间" style="width: 50px;"></Input>　分钟
	            </FormItem>
	            <FormItem label="运动频率:">
	                <Input type="text" v-model="mitionData.sportFrequency" placeholder="请输入运动频率" style="width: 50px;"></Input>　km/h
	            </FormItem>
	            <FormItem label="能耗目标:">
	                <Input type="text" v-model="mitionData.consumeGoal" placeholder="请输入能耗目标" style="width: 50px;"></Input>　千卡
	            </FormItem>
	            <FormItem label="注意事项:">
	                <Input type="textarea" v-model="mitionData.note" :autosize="{minRows: 4}" placeholder="请输入注意事项"></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="motionKeep"  @click="keepMotion('mitionForm')">保存</Button>
	            <Button type="ghost" @click="motionCancel('mitionForm', 'isMotionShow')">取消</Button>
	        </div>
		</Modal>
	
		<!-- 睡眠指导 -->
		<Modal v-model="isSleepShow" :width="600" class-name="eidthform" :mask-closable='false'>
			<p slot="header">睡眠指导编辑</p>
			<Form ref="sleepForm" :model="sleepData" :label-width="10">
				<FormItem label="">
	                <Input type="textarea" :autosize="{minRows: 5}" v-model="sleepData.guidance"  placeholder="Enter something..."></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="sleepKeep"  @click="keepSleep('sleepForm')">保存</Button>
	            <Button type="ghost" @click="sleepCancel('sleepForm', 'isSleepShow')">取消</Button>
	        </div>
		</Modal>
	
		<!-- 心理指导 -->
		<Modal v-model="isPsychologyShow" :width="600" class-name="eidthform" :mask-closable='false'>
			<p slot="header">心理指导编辑</p>
			<Form ref="psychologyForm" :model="psychologyData" :label-width="10">
				<FormItem label="">
	                <Input type="textarea" v-model="psychologyData.psychologyGuidance" :autosize="{minRows: 5}" placeholder="Enter something..."></Input>
	            </FormItem>
			</Form>
			<div slot="footer" class="button-box">
	            <Button type="primary" :loading="psychologyKeep"  @click="keepPsychology('psychologyForm')">保存</Button>
	            <Button type="ghost" @click="psychologyCancel('psychologyForm', 'isPsychologyShow')">取消</Button>
	        </div>
		</Modal>
	</div>
</template>
<!-- 生活方式及改善建议 -->
<script>
	import vTable from '@/components/common/Table.vue'
	export default {
		components: {
			vTable
		},
		data(){
			return {
				customer_id: '',   // 人物id
				ImprovePeriodicalId: '',  //  周刊id
				value: '1',  //  默认展开第一层 
				isInfoShow: false,  //  主体信息  头部
				infoKeep: false,
				isDietShow: false,  //   饮食指导
				dietKeep: false,
				isFoodsShow: false, //  尽量少选的食物
				foodsKeep: false,
				isMotionShow: false,  //运动指导
				motionKeep: false, 
				isSleepShow: false,   //  睡眠指导
				sleepKeep: false,
				isPsychologyShow: false, //   心理指导
				psychologyKeep: false,
				tableColumns: [
			        { title: "身高(cm)", key: "height", align: "center" },
			        { title: "体重(kg)", key: "weight", align: "center" },
//			        { title: "BMI(kg/m²)", key: "name", align: "center" },
//			        { title: "腰围(cm)", key: "date", align: "center" },
//			        { title: "臀围(cm)", key: "address", align: "center" },
			        { title: "理想体重(kg)", key: "dreamWeight", align: "center" },
			        { title: "总热量(kcal)", key: "allCalorie", align: "center" }
//			        {
//                      title: '操作',
//                      key: 'action',
//                      width: 150,
//                      align: 'center',
//                      render: (h, params) => {
//                          return h('div', [
//                              h('Button', {
//                                  props: { type: 'primary', size: 'small' },
//                                  style: { marginRight: '5px' },
//                                  on: {
//                                      click: () => {
//                                      	this.isInfoShow = true;  //  显示就诊指导 弹框
//                                      	this.infoData = JSON.parse(JSON.stringify(params.row))  //  赋值
//                                      	
//                                      }
//                                  }
//                              }, '编辑')
//                          ]);
//                      }
//                  }
				],
				tableColumnsTwo: [
			        { title: "时间", key: "foodCategory", align: "center" },  //摄入量kcal
			        { title: "主食类", key: "stapleFood", align: "center" },
			        { title: "肉蛋白类", key: "proteinFood", align: "center" },
			        { title: "蔬菜类", key: "vegetableFood", align: "center" },
			        { title: "奶类", key: "milkFood", align: "center" },
			        { title: "水果类", key: "fruitFood", align: "center" },
			        { title: "植物油", key: "oil", align: "center" },
			        { title: "食盐", key: "salt", align: "center" },
			        {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: { type: 'primary', size: 'small' },
                                    style: { marginRight: '5px' },
                                    on: {
                                        click: () => {
                                        	this.isDietShow = true;   // 显示饮食指导编辑 弹出框
                                        	this.editFormTitle = '编辑饮食指导';
                                        	this.dietData = JSON.parse(JSON.stringify(params.row));  // 赋值
                                        	this.dietData.customer_id = this.$route.query.customer_id; // 赋值  customer_id
                                        }
                                    }
                                }, '编辑')
                            ]);
                        }
                    }
				],
				tableColumnsThree: [
			        { title: "高升糖指数食品", key: "sugarManyFood", align: "center" },
			        { title: "高升糖指数水果", key: "sugarManyFruit", align: "center" },
			        { title: "高盐食品", key: "saltManyFood", align: "center" },
			        { title: "高胆固醇食品", key: "cholesterolManyFood", align: "center" },
			        { title: "油炸食品", key: "oilFood", align: "center" },
			        { title: "其他加工食品", key: "otherFood", align: "center" },
			        { title: "高嘌呤食物", key: "purineManyFood", align: "center" },
			        {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: { type: 'primary', size: 'small' },
                                    style: { marginRight: '5px' },
                                    on: {
                                        click: () => {
                                        	this.isFoodsShow = true;  // 显示  尽量少选的食物  弹出框
                                        	this.editFormTitle2 = '编辑尽量少选的食物';
                                        	this.foodsData = JSON.parse(JSON.stringify(params.row));  //  赋值
                                        	this.foodsData.customer_id = this.$route.query.customer_id; // 赋值  customer_id
                                        }
                                    }
                                }, '编辑')
                            ]);
                        }
                    }
				],
				tableColumnsFour: [
					{ type: "index", align: "center", width: 60 },
					{ title: "运动方式", key: "sportCategory", align: "center" },
			        { title: "运动强度", key: "sportDose", align: "center" },
			        { title: "运动时间(分钟)", key: "sportTime", align: "center" },
			        { title: "运动频率(km/h)", key: "sportFrequency", align: "center" },
			        { title: "能耗目标(kcal)", key: "consumeGoal", align: "center" },
			        { title: "注意事项", key: "note", align: "center" },
			        {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: { type: 'primary', size: 'small' },
                                    style: { marginRight: '5px' },
                                    on: {
                                        click: () => {
											this.isMotionShow = true;  //  显示  运动指导 弹框
											this.editFormTitle3 = '编辑运动指导';
											this.mitionData = JSON.parse(JSON.stringify(params.row));  // 赋值
											this.mitionData.customer_id = this.$route.query.customer_id; // 赋值  customer_id
                                        }
                                    }
                                }, '编辑')
                            ]);
                        }
                    }
				],
				tableData: [],
				tableData2: [
					{
					 	breakfast: '早餐',
                        staplefood: '米饭、面条1',
                        meat: '鸡蛋1',
                        vegetables: '花菜1',
                        milk: '豆奶1',
                        fruits: '苹果1',
                        vegetableoil: '601',
                        salt: '601'
                    },
                    {
					 	breakfast: '中餐',
                        staplefood: '米饭2',
                        meat: '鸡蛋2',
                        vegetables: '花菜2',
                        milk: '豆奶2',
                        fruits: '苹果2',
                        vegetableoil: '602',
                        salt: '602'
                    },
                    {
					 	breakfast: '晚餐',
                        staplefood: '米饭3',
                        meat: '鸡蛋3',
                        vegetables: '花菜3',
                        milk: '豆奶3',
                        fruits: '苹果3',
                        vegetableoil: '603',
                        salt: '603'
                    },
                    {
					 	breakfast: '加餐',
                        staplefood: '米饭4',
                        meat: '鸡蛋4',
                        vegetables: '花菜4',
                        milk: '豆奶4',
                        fruits: '苹果4',
                        vegetableoil: '604',
                        salt: '604'
                    }
				],
				tableData3: [],
				tableData4: [],
				//  头部信息
				infoData: {
					name: '',
					age: '',
					address: '',
					date: '',
					weight: '',
					height: '',
					kgWeight: ''
				},
				//  饮食指导
				dietData: {
					customer_id: '',
					foodCategory: '',
					stapleFood: '',
					proteinFood: '',
					vegetableFood: '',
					milkFood: '',
					fruitFood: '',
					oil: '',
					salt: '',
					id: ''
				},
				// 尽量少选的食物
				foodsData: {
					customer_id: '',
					sugarManyFood: '',
                    sugarManyFruit: '',
                    saltManyFood: '',
                    cholesterolManyFood: '',
                    oilFood: '',
                    otherFood: '',
                    purineManyFood: '',
                    id: ''
				},
				// 运动指导
				mitionData: {
					customer_id: '',
					sportCategory: '',
                    sportDose: '',
                    sportTime: '',
                    sportFrequency: '',
                    consumeGoal: '',
                    note: '',
                    id: ''
				},
				// 睡眠指导
				sleepData: {
					customer_id: '',
					guidance: '',
					id: ''
				},
				//  心理指导
				psychologyData: {
					customer_id: '',
					psychologyGuidance: '',
					id: ''
				},
				editFormTitle: '',
				editFormTitle2: '',
				editFormTitle3: ''
			}
		},
		created(){
			this.ImprovePeriodicalId = this.$route.params.id;  //  周刊id
			
			this.customer_id = this.$route.query.customer_id;  //  用户id
			//  获取路由id
//			this.customer_id = this.$route.params.id;
			this.dietData.customer_id = this.$route.query.customer_id;  //  用户id
			this.foodsData.customer_id = this.$route.query.customer_id;  //  用户id
			this.sleepData.customer_id = this.$route.query.customer_id;  //  用户id
			this.psychologyData.customer_id = this.$route.query.customer_id;  //  用户id
			this.getData();
		},
		methods: {
			//   清空 饮食指导
			resetDietData(){
				this.dietData.foodCategory = '';
				this.dietData.stapleFood = '';
				this.dietData.proteinFood = '';
				this.dietData.vegetableFood = '';
				this.dietData.milkFood = '';
				this.dietData.fruitFood = '';
				this.dietData.oil = '';
				this.dietData.salt = '';
				this.dietData.id = '';
			},
			// 清空   尽量少选的食物
			resetFoodsData(){
				this.foodsData.sugarManyFood = '';
				this.foodsData.sugarManyFruit = '';
				this.foodsData.saltManyFood = '';
				this.foodsData.cholesterolManyFood = '';
				this.foodsData.oilFood = '';
				this.foodsData.otherFood = '';
				this.foodsData.purineManyFood = '';
				this.foodsData.id = '';
			},
			// 清空 运动指导
			resetMotionData(){
				this.mitionData.sportCategory = '';
                this.mitionData.sportDose = '';
                this.mitionData.sportTime = '';
                this.mitionData.sportFrequency = '';
                this.mitionData.consumeGoal = '';
                this.mitionData.note = '';
                this.mitionData.id = '';
			},
			// 获取数据
			getData(){
				// 并发请求
				const diet_guidanceApi = '/improve/diet_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId; //  查询生活方式的基本资料
				const food_detailApi = '/improve/food_detail/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;   // 查询饮食指导 + 
				const not_recommend_foodApi = '/improve/not_recommend_food/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;  //尽量少选的食物
				const sport_guidanceApi = '/improve/sport_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId; 	//查询运动指导
				const sleep_guidanceApi = '/improve/sleep_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;   //查询睡眠指导
				const psychology_guidanceApi = '/improve/psychology_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId; // 查询心理指导
				this.$http.all([
					this.$http.get(diet_guidanceApi),
					this.$http.get(food_detailApi),
					this.$http.get(not_recommend_foodApi),
					this.$http.get(sport_guidanceApi),
					this.$http.get(sleep_guidanceApi),
					this.$http.get(psychology_guidanceApi)
				])
				.then(this.$http.spread((res1,res2,res3,res4,res5,res6)=>{
					console.log(res2)
					if(res1.data.data !== null){
						this.tableData = [res1.data.data];
					}
					if(res2.data.data !== null){
						this.tableData2 = res2.data.data;
					}
					if(res3.data.data !== null){
						this.tableData3 = [res3.data.data];  //   因为这是个对象，所以需要加  [  ];
					}
					if(res4.data.data !== null){
						this.tableData4 = res4.data.data;
					}
					if(res5.data.data !== null){
						this.sleepData.guidance = res5.data.data.guidance;
						this.sleepData.id = res5.data.data.id;
					}
					if(res6.data.data !== null){
						this.psychologyData.psychologyGuidance = res6.data.data.psychologyGuidance;
						this.psychologyData.id = res6.data.data.id;
					}
					
				}))
			},
			
			//  显示饮食指导 弹框
			showDiet(){
				this.editFormTitle = '新增饮食指导';
				this.isDietShow = true;
				this.resetDietData();  // 清空  dietData  数据
			},
			//  修改 饮食指导  
			editDiet(){
				const update_food_guidance = '/improve/update_food_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(update_food_guidance,[this.dietData])
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isDietShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  新增 饮食指导      
			addDiet(){
				const add_food_guidance = '/improve/add_food_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(add_food_guidance, this.dietData)
				.then((res)=>{
					this.getData();
					this.isDietShow = false;
				})
				.catch((err)=>{
					console.log(err);
				})
			},
			//  保存饮食指导 编辑
			keepDiet(refName){
				// 通过 判断 标题来 请求接口 
				if(this.editFormTitle === '新增饮食指导') {
					this.addDiet()
				} else {
					this.editDiet()
				}
			},
			//  取消 饮食指导  弹框 
			dietCancel(refName, showName){
				this.$refs[refName].resetFields();
				this[showName] = false;
			},
			
			// 显示  尽量少选的食物 弹框
			showFoods(){
				this.editFormTitle2 = '新增尽量少选的食物';
				this.isFoodsShow = true;
				this.resetFoodsData();  // 清空  dietData  数据
			},
			// 修改  尽量少选的食物      
			editFoods(){
				const update_not_recommend_food = '/improve/update_not_recommend_food/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(update_not_recommend_food, this.foodsData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isFoodsShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  新增   尽量少选的食物    
			addFoods(){
				const add_not_recommend_food = '/improve/add_not_recommend_food/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(add_not_recommend_food, this.foodsData)
				.then((res)=>{
					console.log(res);
					if(res.data.status === 1){
						this.$Notice.warning({
							title: res.data.message
						})
					}
					this.getData();
					this.isFoodsShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			// 保存 尽量少选的食物 编辑
			keepFoods(refName){
				// 通过 判断 标题来 请求接口 
				if(this.editFormTitle2 === '新增尽量少选的食物') {
					this.addFoods();
				} else {
					this.editFoods();
				}
			},
			//  取消 尽量少选的食物  弹框
			foodsCancel(refName, showName){
				this.$refs[refName].resetFields();
				this[showName] = false;
			},
			
			// 先是 运动指导 编辑 
			showMotion(){
				this.editFormTitle3 = '新增运动指导';
				this.isMotionShow = true;
				this.resetMotionData();  // 清空  MotionData  数据
			},
			// 修改 运动指导 
			editMotion(){
				const update_sport_guidance = '/improve/update_sport_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(update_sport_guidance, [this.mitionData])
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isMotionShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			// 新增  运动指导 
			addMotion(){
				const add_sport_guidance = '/improve/add_sport_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(add_sport_guidance, this.mitionData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isMotionShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  保存 运动指导 编辑
			keepMotion(refName){
				// 通过 判断 标题来 请求接口 
				if(this.editFormTitle3 === '新增运动指导') {
					this.addMotion();
				} else {
					this.editMotion();
				}
			},
			//  取消 运动指导  弹框
			motionCancel(refName, showName){
				this.$refs[refName].resetFields();
				this[showName] = false;
			},
			
			//  显示 睡眠指导 弹框
			showSleep(){
				this.isSleepShow = true;
			},
			// 修改 睡眠指导   
			editSleep(){
				const update_sleep_guidance = '/improve/update_sleep_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(update_sleep_guidance, this.sleepData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isSleepShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			// 添加 睡眠指导  
			addSleep(){
				const add_sleep_guidance = '/improve/add_sleep_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(add_sleep_guidance, this.sleepData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isSleepShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  保存 睡眠指导 编辑
			keepSleep(refName){
				// 通过 判断 sleepData的id 是否有id来   请求接口 
				if(this.sleepData.id !== '') {
					this.editSleep();
				} else {
					this.addSleep();
				}
			},
			//  取消 睡眠指导  弹框
			sleepCancel(refName, showName){
				this.$refs[refName].resetFields();
				this[showName] = false;
				this.sleepData.values = '';  //  取消弹框  清空value 
			},
			
			//  显示 心理指导 弹框
			showPsychology(){
				this.isPsychologyShow = true;
			},
			//  修改  心理指导 
			editPsychology(){
				const update_psychology_guidance = '/improve/update_psychology_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(update_psychology_guidance, this.psychologyData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isPsychologyShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  新增 心理指导
			addPsychology(){
				const add_psychology_guidance = '/improve/add_psychology_guidance/' + this.customer_id + '?ImprovePeriodicalId=' + this.ImprovePeriodicalId;
				this.$http.post(add_psychology_guidance, this.psychologyData)
				.then((res)=>{
					console.log(res);
					this.getData();
					this.isPsychologyShow = false;
				})
				.catch((err)=>{
					console.log(err)
				})
			},
			//  保存 心理指导 编辑
			keepPsychology(refName){
				// 通过 判断 psychologyData psychologyGuidance  是否有id来   请求接口 
				if(this.psychologyData.id !== '') {
					this.editPsychology();
				} else {
					this.addPsychology();
				}
			},
			//  取消 心理指导  弹框
			psychologyCancel(refName, showName){
				this.$refs[refName].resetFields();
				this[showName] = false;
				this.psychologyData.values = '';  //  取消弹框  清空value 
			}
		}
	}
</script>

<style lang="less" scoped>
	.lifeStyle{
		margin-left: 30px;
		.collapse {
			margin-top: 30px;
			
			.wrapbox {
				margin: 20px;
				.header{
					height: 40px;
					text-align: center;
					font-size: 20px;
					line-height: 40px;
					color: #fff;
					background: #0B9595;
					border-radius: 5px;
				}
				.button-box {
					width: 100%;
					text-align: center;
					
					.editTarget {
						margin-top: 20px;
					}
				}
				.remarks {
					margin-top: 10px;
				}
			}
		}
	}
</style>